/**
 * Copyright (c) 2008 Andrew Rapp. All rights reserved.
 *  
 * This file is part of XBee-API.
 *  
 * XBee-API is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *  
 * XBee-API is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *  
 * You should have received a copy of the GNU General Public License
 * along with XBee-API.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.rapplogic.xbee.api;

import java.util.HashMap;
import java.util.Map;

public class ModemStatusResponse extends XBeeResponse {

    public /*enum*/ static class Status {

        public static final Status HARDWARE_RESET = new Status(0);
        public static final Status WATCHDOG_TIMER_RESET = new Status(1);
        public static final Status ASSOCIATED = new Status(2);
        public static final Status DISASSOCIATED = new Status(3);
        public static final Status SYNCHRONIZATION_LOST = new Status(4);
        public static final Status COORDINATOR_REALIGNMENT = new Status(5);
        public static final Status COORDINATOR_STARTED = new Status(6);
        private static final Map lookup = new HashMap();


        static {
            lookup.put(HARDWARE_RESET.getValue(), HARDWARE_RESET);
            lookup.put(WATCHDOG_TIMER_RESET.getValue(), WATCHDOG_TIMER_RESET);
            lookup.put(ASSOCIATED.getValue(), ASSOCIATED);
            lookup.put(DISASSOCIATED.getValue(), DISASSOCIATED);
            lookup.put(SYNCHRONIZATION_LOST.getValue(), SYNCHRONIZATION_LOST);
            lookup.put(COORDINATOR_REALIGNMENT.getValue(), COORDINATOR_REALIGNMENT);
            lookup.put(COORDINATOR_STARTED.getValue(), COORDINATOR_STARTED);

        }

        public static Status get(int value) {
            return (Status) lookup.get(new Integer(value));
        }
        private final int value;

        Status(int value) {
            this.value = value;
        }

        public Integer getValue() {
            return new Integer(value);
        }

        public String toString() {
            switch (value) {
                case 0:
                    return "HARDWARE_RESET";
                case 1:
                    return "WATCHDOG_TIMER_RESET";
                case 2:
                    return "ASSOCIATED";
                case 3:
                    return "DISASSOCIATED";
                case 4:
                    return "SYNCHRONIZATION_LOST";
                case 5:
                    return "COORDINATOR_REALIGNMENT";
                case 6:
                    return "COORDINATOR_STARTED";
                default:
                    return "Undefined";

            }
        }
    }
    private Status status;

    public ModemStatusResponse() {
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public String toString() {
        return super.toString() + ",status=" + this.status;
    }
}